package com.hotelManagerSystem.controller;


import com.hotelManagerSystem.model.DishOrder;
import com.hotelManagerSystem.service.IDishOrderService;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author treasy
 * @since 2021-12-22
 */
@Controller
@RequestMapping("/dish-order")
public class DishOrderController {
    @Autowired
    IDishOrderService iDishOrderService;

    @RequestMapping("/dishOrderUI")
    public String dishOrderUI() {
        return "dish/dish-order-list";
    }

    @ResponseBody
    @RequestMapping("/add")
    public Map<String, Object> add(DishOrder dishOrder) {
        System.out.println(dishOrder);
        return iDishOrderService.addOne(dishOrder);
    }

    @ResponseBody
    @RequestMapping("/list")
    public Map<String, Object> list() {
        return iDishOrderService.queryAll();
    }

    @ResponseBody
    @RequestMapping("/del/{id}")
    public Map<String, Object> del(@PathVariable("id") Integer id) {
        return iDishOrderService.delOne(id);
    }

    @ResponseBody
    @RequestMapping Map<String, Object> queryByRoomId(Integer id) {
        return  iDishOrderService.queryByRoomId(id);
    }
}

